<template>
    <div class="user-view">
        <div class="user-profile">
            <img src="../assets/wxtx.jpg" class="profile-img">
            <div class="login-out-view">
                <div class="login-out-text" @click="loginOut">退出登录</div>
            </div>
        </div>
        <div class="hello-text">您好，胡丙志</div>
    </div>
</template>

<script setup>
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()
const loginOut = () => {
    localStorage.removeItem('periodValidity')
    localStorage.removeItem('token')
    router.push('/login?redirect=' + route.fullPath)
}
</script>

<style scoped>
.user-view {
    height: 60px;
    float: right;    
}
.hello-text {
    height: 60px;
    line-height: 60px;
    float: right;
}
.user-profile {
    height: 60px;
    width: 60px;
    float: right;
    cursor: pointer;
    position: relative;
}
.user-profile:hover .login-out-view {
    display: block;
}
.login-out-view {
    width: 120px;
    border-radius: 4px;
    right: 6px;
    top: 54px;
    display: none;
    box-shadow: 0 0 10px #00000048;
    background: #ffffff;
    position: absolute;
}
.login-out-text {
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 14px;
    color: #000000;
}
.login-out-text:hover {
    background: #f5f5f5;
}
.profile-img {
    width: 35px;
    height: 35px;
    border-radius: 18px;
    margin: 12px;
    background: #ccc;
    box-shadow: 0 0 10px #00000048;
}
</style>